<html>
<head><meta charset="utf-8"><title>resolve_path between fixture files · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html">resolve_path between fixture files</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196118179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118179">(May 03 2020 at 19:20)</a>:</h4>
<p>Hey all, I've created the following fixture for my work on <a href="https://github.com/rust-analyzer/rust-analyzer/pull/4273" title="https://github.com/rust-analyzer/rust-analyzer/pull/4273">https://github.com/rust-analyzer/rust-analyzer/pull/4273</a>:</p>
<div class="codehilite"><pre><span></span><code>            r&quot;//- /main.rs
              mod foo;
              fn main() { foo::Foo&lt;|&gt; }

              //- /foo.rs
              struct Foo;
              &quot;,
            r&quot;
</code></pre></div>


<p>But <code>resolve_path</code> can't resolve the path <code>foo::Foo</code>.<br>
Testing the same case manually works, so something is broken with the test setup.<br>
Can anyone tell me what I'm doing wrong?</p>



<a name="196118198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118198">(May 03 2020 at 19:21)</a>:</h4>
<p>pub struct Foo; ?</p>



<a name="196118543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118543">(May 03 2020 at 19:30)</a>:</h4>
<p>well that's what the assist is meant to add :/<br>
it works in a manual test!</p>



<a name="196118581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118581">(May 03 2020 at 19:31)</a>:</h4>
<p>and even with <code>pub struct Foo;</code>, <code>resolve_path</code> returns <code>None</code></p>



<a name="196118749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118749">(May 03 2020 at 19:34)</a>:</h4>
<p><code>r"//-</code> could you add a <code>\n</code> here? perhaps "strip indent" logic is going haywire?</p>



<a name="196118751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118751">(May 03 2020 at 19:34)</a>:</h4>
<p>try this:</p>
<div class="codehilite"><pre><span></span><code><span class="w">    </span><span class="cp">#[test]</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">change_visibility_of_adt_in_other_file_via_path</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">check_assist</span><span class="p">(</span><span class="w"></span>
<span class="w">            </span><span class="n">change_visibility</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="n">r</span><span class="s">&quot;</span>
<span class="s">              //- /main.rs</span>
<span class="s">              mod foo;</span>
<span class="s">              fn main() { foo::Foo&lt;|&gt; }</span>

<span class="s">              //- /foo.rs</span>
<span class="s">              struct Foo;</span>
<span class="s">              &quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="n">r</span><span class="s">&quot;</span>
<span class="s">            &lt;|&gt;pub(crate) struct Foo;</span>
<span class="s">            &quot;</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="196118769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118769">(May 03 2020 at 19:34)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> yes, I just tried my version, it works</p>



<a name="196118784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118784">(May 03 2020 at 19:35)</a>:</h4>
<p>yep that's it.<br>
thanks a ton!</p>



<a name="196118791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118791">(May 03 2020 at 19:35)</a>:</h4>
<p>(also, the format of fixtures needs some docs... I regularly forget the syntax myself :( )</p>



<a name="196118805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Timo Freiberg <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118805">(May 03 2020 at 19:35)</a>:</h4>
<p>i'm gonna try to improve those areas a bit in the PR while I'm there :)</p>



<a name="196118808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118808">(May 03 2020 at 19:35)</a>:</h4>
<p>And, in this particular case, seems like we can implement some sort of a check? basically, <code>if any file contains "//-" panic!(":-(")</code></p>



<a name="196118855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118855">(May 03 2020 at 19:36)</a>:</h4>
<p>Speaking of formatting, any plan to works on <code>ra_fmt</code> ?</p>



<a name="196118886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196118886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196118886">(May 03 2020 at 19:37)</a>:</h4>
<p>I would like to implement it for better output of expanded macro display .... but it seem like needing more design works.</p>



<a name="196119067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196119067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196119067">(May 03 2020 at 19:40)</a>:</h4>
<p>fwiw, I kinda like IntelliJ's design</p>



<a name="196119104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196119104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196119104">(May 03 2020 at 19:41)</a>:</h4>
<p>The problem is, it's not trivial to understand what that design is, among thousands of highly OOP Java loc :D</p>



<a name="196119645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/resolve_path%20between%20fixture%20files/near/196119645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edwin Cheng <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/resolve_path.20between.20fixture.20files.html#196119645">(May 03 2020 at 19:51)</a>:</h4>
<p><a href="https://www.jetbrains.org/intellij/sdk/docs/reference_guide/custom_language_support/code_formatting.html" title="https://www.jetbrains.org/intellij/sdk/docs/reference_guide/custom_language_support/code_formatting.html">https://www.jetbrains.org/intellij/sdk/docs/reference_guide/custom_language_support/code_formatting.html</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>